package bstsetcode;



/**
 * @author noob
 * @version 1.0
 * @date 2021/3/13 9:45
 */
public class LinearSearch {


    private LinearSearch() {
    }

    public static int search(int[] data, int target){

        for (int i = 0; i < data.length; i++) {
            if(data[i]==target){
                return i;
            }
        }
        return -1;
    }


    public static void main(String[] args) {
        int[] data = {39, 71, 91, 90 ,51, 83, 70, 80, 26, 8};
        int res = LinearSearch.search(data, 91);
        System.out.println(res);

        int res2 = LinearSearch.search(data, 520);
        System.out.println(res2);
    }




}
